home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / MacApp Documentation / MacApp.TECH$ Archives / 1990 / Apr 90 / MacApp.Tech$ 4⁄27⁄90 / 1203-Re TAssociation Ques-Apr90 < prev    next >
Encoding:
Text File  |  1991-03-06  |  1.8 KB  |  45 lines  |  [TEXT/GEOL]

  1. Item forwarded  by  A33          to A34
  2.  
  3. Item    6441297                         25-April-90        08:11PDT
  4.  
  5. From:   ALGER                           Alger, Jeff,VCA
  6.  
  7. To:     D4281                           IDS, Larry Forbord,AST
  8.  
  9. cc:     MACAPP.TECH$                    MacApp Technical
  10.  
  11. Sub:    Re: TAssociation Question
  12.  
  13. Larry,
  14.  
  15. The problem with a many-to-many TAssociation is not storing the pairs, it is
  16. retrieval.  There are no methods provided to iterate over the values associated
  17. with a given key: there is a built-in presumption that the key uniquely
  18. determines a single value.  For what it is worth, I will share a solution
  19. derived for a prior project.
  20.  
  21. A "multiset" or "bag" in set theory is a set whose elements are not necessarily
  22. distinct.  In my TMultiSet, two objects might be different objects, yet be
  23. considered "equal" in the set based on some comparison function.  Comparing the
  24. key parts of key-value pairs would qualify.
  25.  
  26. The principal method for access was EachMatch method, which iterated over all
  27. matching elements of the set given a "template" object against which to
  28. compare.  Also provided were iterators in first-next and last-previous fashion
  29. (using greatest lower bound and least upper bound as starting points,
  30. respectively) and these combined to provide range searching.  These were also
  31. used to implement deletion: in your situation, deletion of a key should delete
  32. all values associated with it.
  33.  
  34. You could probably hack up TAssociation by adding the EachMatch method, but
  35. probably would find it easier all around to just implement a new class.
  36. Adapting the binary search algorithm for a multiset is a non-trivial problem.
  37. Better yet, since the code I implemented is owned by Apple, maybe they can be
  38. convinced to release it (are you listening Steve?)
  39.  
  40. Regards,
  41. Jeff Alger
  42. Exis
  43. A Technology Firm of KPMG Peat Marwick
  44.  
  45.